package com.cskaoyan.bean;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
//@Scope("prototype")//如果是singleton可以直接省略不写
public class LifeCycleBean implements ApplicationContextAware {

    @PostConstruct
    public void customInit() {
        System.out.println("自定义init方法");
    }
    @PreDestroy
    public void customDestroy() {
        System.out.println("自定义destroy方法");
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {

    }
}
